In [1]:
import astropy.coordinates as coord
from astropy.io import ascii
import astropy.table as at
import astropy.units as u
import numpy as np
from matplotlib.gridspec import GridSpec
import matplotlib.pyplot as plt
%matplotlib inline

import gary.coordinates as gc

Data for observed stars


In [2]:
from astropy.coordinates.matching import match_coordinates_sky

In [27]:
rrlyr_d = np.genfromtxt("/Users/adrian/projects/triand-rrlyrae/data/mdm-targets.txt", dtype=None, names=True)

In [28]:
rrlyr_d


Out[28]:
array([ ('TriAndRRL1', 35.804598, 31.551122, 0.6297892, 55889.67436, 0.724, 17.902, 112, 0.181, 18.131),
       ('TriAndRRl2', 30.59351, 33.377335, 0.6043698, 55763.907589, 0.515, 16.902, 105, 0.208, 16.965),
       ('TriAndRRl3', 28.380832, 30.584897, 0.5817013, 55899.726836, 0.966, 17.151, 116, 0.14, 17.597),
       ('TriAndRRl4', 24.505426, 32.027878, 0.5610494, 55892.613891, 0.68, 17.373, 107, 0.149, 17.595),
       ('TriAndRRl5', 22.322702, 32.72186, 0.5129024, 55853.589624, 0.7, 16.891, 116, 0.148, 17.177),
       ('TriAndRRl6', 12.488351, 42.598328, 0.6189352, 55820.651431, 0.357, 16.523, 101, 0.222, 16.486),
       ('TriAndRRl7', 11.310251, 42.705384, 0.5819742, 55757.857652, 0.499, 16.482, 104, 0.219, 16.524),
       ('TriAndRRl8', 17.992175, 35.466819, 0.6438835, 56272.808192, 0.347, 17.201, 101, 0.151, 17.23),
       ('TriAndRRl9', 11.491072, 40.199252, 0.5191218, 55774.793032, 0.775, 16.636, 116, 0.18, 16.934),
       ('TriAndRRl10', 16.841753, 32.235145, 0.4767494, 56258.826942, 0.973, 16.217, 116, 0.167, 16.64),
       ('TriAndRRl11', 9.262168, 38.824378, 0.6286307, 55899.583961, 0.367, 16.68, 103, 0.151, 16.727),
       ('TriAndRRl12', 12.887871, 34.28071, 0.5708534, 56231.918816, 0.831, 17.026, 118, 0.279, 17.237),
       ('TriAndRRl13', 8.323077, 37.502618, 0.605721, 56265.64237, 0.433, 18.191, 100, 0.168, 18.235),
       ('TriAndRRl14', 7.316877, 37.832822, 0.5361401, 56233.871843, 0.776, 17.176, 112, 0.161, 17.453),
       ('TriAndRRl15', 8.828356, 36.304111, 0.5994482, 56237.939283, 0.798, 16.461, 110, 0.168, 16.725),
       ('TriAndRRl16', 10.495088, 33.834552, 0.5099844, 56258.839841, 0.834, 16.439, 112, 0.244, 16.663),
       ('TriAndRRl17', 11.420589, 31.895553, 0.5194712, 56203.614781, 0.771, 16.282, 112, 0.236, 16.481),
       ('TriAndRRl18', 9.956522, 32.429326, 0.5740692, 56272.769061, 0.752, 16.876, 119, 0.223, 17.113),
       ('TriAndRRl19', 351.051857, 32.899191, 0.4542834, 55046.805814, 1.067, 17.296, 119, 0.375, 17.559),
       ('TriAndRRl20', 5.576572, 36.203326, 0.6826233, 56229.917435, 0.537, 16.545, 105, 0.186, 16.641),
       ('TriAndRRl21', 352.155077, 33.73084, 0.5913201, 56239.726193, 0.548, 17.362, 110, 0.297, 17.367),
       ('TriAndRRl22', 353.523696, 34.806522, 0.634024, 56226.528309, 0.686, 17.01, 107, 0.281, 17.104),
       ('TriAndRRl23', 352.977933, 34.21691, 0.6201623, 56197.71663, 0.469, 17.138, 104, 0.315, 17.07),
       ('TriAndRRl24', 353.000072, 33.44693, 0.5104113, 55782.967115, 0.934, 16.293, 114, 0.247, 16.581),
       ('TriAndRRl25', 353.576571, 33.945158, 0.5268401, 55519.664379, 0.73, 16.881, 106, 0.236, 17.049),
       ('TriAndRRl26', 351.509509, 30.571749, 0.5281412, 56232.636689, 0.75, 17.395, 116, 0.539, 17.319),
       ('TriAndRRl27', 355.466314, 33.808053, 0.5673953, 55813.943244, 0.768, 16.994, 112, 0.199, 17.229),
       ('TriAndRRl28', 2.822702, 34.243251, 0.5633701, 55514.634149, 0.69, 16.391, 116, 0.131, 16.688),
       ('TriAndRRl29', 0.350222, 36.141364, 0.5029317, 56207.678085, 1.135, 17.276, 106, 0.309, 17.574),
       ('TriAndRRl30', 1.605007, 34.567764, 0.6251911, 56204.766799, 0.453, 18.159, 106, 0.156, 18.26),
       ('TriAndRRl31', 354.620544, 30.140181, 0.558377, 56234.646836, 0.73, 17.402, 116, 0.258, 17.596),
       ('TriAndRRl32', 356.154789, 30.168917, 0.5399409, 56234.597284, 0.798, 17.194, 109, 0.364, 17.27),
       ('TriAndRRl33', 1.014094, 32.019259, 0.6935978, 56239.834007, 0.597, 16.898, 104, 0.135, 17.073),
       ('TriAndRRl34', 359.193996, 31.672904, 0.5732184, 55771.935045, 0.581, 17.05, 113, 0.141, 17.254)], 
      dtype=[('name', 'S11'), ('ra', '<f8'), ('dec', '<f8'), ('period', '<f8'), ('hjd0', '<f8'), ('amp', '<f8'), ('mag0', '<f8'), ('template', '<i8'), ('rExt', '<f8'), ('Vmag', '<f8')])

In [29]:
0.01*10**(0.2*(rrlyr_d['Vmag'] - 0.6))


Out[29]:
array([ 32.07746206,  18.74994508,  25.08418528,  25.06109253,
        20.67283318,  15.03834348,  15.30382532,  21.18361135,
        18.48417195,  16.14358557,  16.80350966,  21.25200943,
        33.65115694,  23.47469725,  16.78804018,  16.31548544,
        15.00375625,  20.07243222,  24.64903946,  16.15102168,
        22.563164  ,  19.98941111,  19.6788629 ,  15.7108615 ,
        19.4894687 ,  22.06988143,  21.17385818,  16.50440986,
        24.81989844,  34.04081897,  25.07263625,  21.57744409,
        19.70606904,  21.41903991])

In [3]:
rrlyr_d = np.genfromtxt("/Users/adrian/projects/triand-rrlyrae/data/RRL_ALL.txt", 
                        skiprows=2, dtype=None, names=['l','b','vhel','vgsr','src','ra','dec','name','dist'])
rrlyr_d_new = np.genfromtxt("/Users/adrian/projects/triand-rrlyrae/data/TriAnd_RRL_19mar15.csv", 
                            skiprows=0, dtype=None, names=True, delimiter=',')

ix = (rrlyr_d['dist'] > 15) & (rrlyr_d['dist'] < 21)
obs_rrlyr = rrlyr_d[ix]

In [18]:
rrlyr_d.dtype.names, rrlyr_d_new.dtype.names


Out[18]:
(('l', 'b', 'vhel', 'vgsr', 'src', 'ra', 'dec', 'name', 'dist'),
 ('oname', 'name', 'ra', 'dec', 'amp', 'Vsys', 'Err'))

In [6]:
idx,a,b = match_coordinates_sky(coord.Galactic(l=rrlyr_d['l']*u.deg, b=rrlyr_d['b']*u.deg),
                                coord.ICRS(ra=rrlyr_d_new['ra']*u.deg, dec=rrlyr_d_new['dec']*u.deg))

In [22]:
# print(rrlyr_d_new[idx][:5])
# print(rrlyr_d['dist'])
rrlyr_d_new, rrlyr_d


Out[22]:
(array([('RRL2', 'TriAndRRl26', 351.509509, 30.571749, 0.75, -197, 20),
        ('RRL3', 'TriAndRRl21', 352.155077, 33.73084, 0.548, -266, 16),
        ('RRL4', 'TriAndRRl23', 352.977933, 34.21691, 0.469, -84, 23),
        ('RRL5', 'TriAndRRl24', 353.000072, 33.44693, 0.934, -303, 25),
        ('RRL8', 'TriAndRRl31', 354.620544, 30.140181, 0.73, -318, 24),
        ('RRL9', 'TriAndRRl27', 355.466314, 33.808053, 0.768, -227, 18),
        ('RRL10', 'TriAndRRl32', 356.154789, 30.168917, 0.798, -176, 25),
        ('RRL13', 'TriAndRRl33', 1.014094, 32.019259, 0.597, -86, 20),
        ('RRL14', 'TriAndRRl30', 1.605007, 34.567764, 0.453, -226, 25),
        ('RRL16', 'TriAndRRl20', 5.576572, 36.203326, 0.537, -128, 25),
        ('RRL19', 'TriAndRRl15', 8.828356, 36.304111, 0.798, -85, 16),
        ('RRL20', 'TriAndRRl11', 9.262168, 38.824378, 0.367, -132, 22),
        ('RRL22', 'TriAndRRl16', 10.495088, 33.834552, 0.834, -194, 25),
        ('RRL25', 'TriAndRRl9', 11.491072, 40.199252, 0.775, -154, 18),
        ('RRL27', 'TriAndRRl12', 12.887871, 34.28071, 0.831, -25, 22),
        ('RRL28', 'TriAndRRl10', 16.841753, 32.235145, 0.973, -283, 18),
        ('RRL29', 'TriAndRRl8', 17.992175, 35.466819, 0.347, -126, 19),
        ('RRL30', 'TriAndRRl5', 22.322702, 32.72186, 0.7, -214, 20),
        ('RRL33', 'TriAndRRl2', 30.59351, 33.377335, 0.515, -242, 19),
        ('RRL34', 'TriAndRRL1', 35.804598, 31.551122, 0.724, -157, 22)], 
       dtype=[('oname', 'S5'), ('name', 'S11'), ('ra', '<f8'), ('dec', '<f8'), ('amp', '<f8'), ('Vsys', '<i8'), ('Err', '<i8')]),
 array([ (121.799, -22.66, -134.9, 51.6, 'PTF', 11.49059, 40.19962, 'TriAndRRL9', 18.48),
        (120.687, -28.996, -150.5, 27.8, 'PTF', 10.4955, 33.83444, 'TriAndRRL16', 16.32),
        (101.973, -28.801, -200.0, 7.3, 'PTF', 351.50989, 30.57158, 'TriAndRRL26', 22.07),
        (116.38, -26.298, -100.0, 91.7, 'PTF', 5.57648, 36.20277, 'TriAndRRL20', 16.15),
        (104.457, -26.559, -263.2, -53.9, 'PTF', 353.00046, 33.44686, 'TriAndRRL24', 15.71),
        (106.765, -26.87, -197.0, 8.9, 'PTF', 355.46661, 33.80812, 'TriAndRRL27', 21.17),
        (111.364, -29.786, -43.5, 150.0, 'PTF', 1.0145, 32.01915, 'TriAndRRL33', 19.71),
        (144.902, -27.375, -103.2, 12.2, 'PTF', 35.80513, 31.55133, 'TriAndRRL1', 32.08),
        (127.632, -27.218, -67.0, 98.5, 'PTF', 17.99234, 35.46623, 'TriAndRRL8', 21.18),
        (103.828, -26.05, -239.4, -28.4, 'PTF', 352.15465, 33.73073, 'TriAndRRL21', 22.56),
        (112.504, -27.391, -243.3, -46.8, 'PTF', 1.60533, 34.56747, 'TriAndRRL30', 34.04),
        (119.304, -26.454, -41.7, 144.0, 'PTF', 8.82837, 36.30405, 'TriAndRRL15', 16.79),
        (119.866, -23.962, -114.6, 74.1, 'PTF', 9.26259, 38.824, 'TriAndRRL11', 16.8),
        (122.959, -28.591, 1.4, 175.5, 'PTF', 12.88819, 34.28066, 'TriAndRRL12', 21.25),
        (126.842, -30.516, -242.5, -80.8, 'PTF', 16.8418, 32.2347, 'TriAndRRL10', 16.14),
        (132.075, -29.477, -180.8, -30.4, 'PTF', 22.32322, 32.72172, 'TriAndRRL5', 20.67),
        (111.285, -22.371, -335.3, -127.9, 'CSS', 358.91235, 39.23563, 'CSS1', 15.38)], 
       dtype=[('l', '<f8'), ('b', '<f8'), ('vhel', '<f8'), ('vgsr', '<f8'), ('src', 'S3'), ('ra', '<f8'), ('dec', '<f8'), ('name', 'S11'), ('dist', '<f8')]))

In [11]:
c = coord.SkyCoord(ra=rrlyr_d_new['ra']*u.deg, dec=rrlyr_d_new['dec']*u.deg)
rrl_l = c.galactic.l
rrl_vgsr = gc.vhel_to_vgsr(c, rrlyr_d_new['Vsys']*u.km/u.s,
                           vcirc=236.*u.km/u.s,
                           vlsr=[11.1,12.24,7.25]*u.km/u.s).value # same as Sheffield et al. 2014
verr = rrlyr_d_new['Err']

M-giant data


In [12]:
mgiants = np.genfromtxt("/Users/adrian/projects/triand-rrlyrae/data/triand_giants.txt", names=True)
mgiants.dtype.names


Out[12]:
('l', 'b', 'vr', 'ra', 'dec')

In [13]:
high_prob_ix = np.array([False, False, False, False, False, False, True, True, True, True, True, False, True, True, False, False, False, False, True, True, False, False, True, False, False, False, False, False, False, False, False, True, True, True, True, False, True, True, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True, False, True, True, False, True, True, True, False, True, False, True, True, True, True, True, False, True, False, False, True, True, False, True, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True, False, False, True, True, True, False, False, False, False, False, True, False, True, False, True, True, True, True, True, True, True, True, True, False])

In [14]:
fig = plt.figure(figsize=(16,8))

gs = GridSpec(1, 4)
ax1 = fig.add_subplot(gs[:3])
ax2 = fig.add_subplot(gs[3])

# ax1.plot(mgiants['l'], mgiants['vr'], linestyle='none', 
#          marker='o', ms=5, color='#777777')
# ax1.plot(mgiants['l'][high_prob_ix], mgiants['vr'][high_prob_ix], linestyle='none', 
#          marker='o', ms=5, color='#777777')
ax1.errorbar(rrl_l.value, rrl_vgsr, verr, linestyle='none', 
             marker='s', ms=8., color='k', ecolor='k', elinewidth=2)
ax1.set_xlim(165, 95)
ax1.set_xlabel(r"$l\,{\rm [deg]}$", fontsize=26)
ax1.set_ylabel(r"$v_{\rm GSR}\,{\rm km} \, {\rm s}^{-1}$", fontsize=26)

# lines
m,b,vg = (-0.776851028033, 139.823102439, 17.4792917207)
ls = np.linspace(170, 90, 100)
ax1.plot(ls, m*ls + b, color='k', alpha=0.6, marker=None, linestyle='-', lw=2.)
ax1.plot(ls, m*ls + b + vg, color='k', alpha=0.6, marker=None, linestyle='--', lw=2.)
ax1.plot(ls, m*ls + b - vg, color='k', alpha=0.6, marker=None, linestyle='--', lw=2.)

bins = np.linspace(-300, 300, 26)
# ax2.hist(mgiants['vr'], bins=bins, orientation='horizontal', color='#aaaaaa', label='M-giants')
ax2.hist(mgiants['vr'][high_prob_ix], bins=bins, orientation='horizontal', color='#aaaaaa', label='M-giants')
ax2.hist(rrl_vgsr, bins=bins, orientation='horizontal', color='k', label='RR Lyrae')
ax2.legend(loc='upper center', fontsize=20)

ax2.set_xlabel("$N$", fontsize=26)
ax2.yaxis.set_ticklabels([])

ax1.set_ylim(bins.min(), bins.max())
ax2.set_ylim(bins.min(), bins.max())

fig.subplots_adjust(wspace=0)



In [14]:


In [ ]: